# U-Boot: USB armory Mk II
# Maintainer: Kevin Mihelich <kevin@archlinuxarm.org>

buildarch=4

pkgname=uboot-usbarmory-mkii
pkgver=2019.07
pkgrel=2
pkgdesc="U-Boot for USB armory Mk II"
arch=('armv7h')
url="http://git.denx.de/u-boot.git/"
license=('GPL')
makedepends=('git' 'bc')
install=${pkgname}.install
backup=('boot/boot.txt' 'boot/boot.scr')
source=("ftp://ftp.denx.de/pub/u-boot/u-boot-${pkgver}.tar.bz2"
        '0001-ARM-mx6-add-support-for-USB-armory-Mk-II-board.patch'
        '0002-arch-linux-arm-modifications.patch'
        'boot.txt'
        'mkscr')
md5sums=('73434338536c7500b4302bd0a02921ed'
         'd573e51bad231edd3c2f80eaca11fded'
         'e7187d62bff6509cdbeec6a9398072bc'
         '9f0f7aa1a7c3ed679ae9d43516155bd8'
         '021623a04afd29ac3f368977140cfbfd')

prepare() {
  cd u-boot-${pkgver}
  
  patch -p1 -i ../0001-ARM-mx6-add-support-for-USB-armory-Mk-II-board.patch
  patch -p1 -i ../0002-arch-linux-arm-modifications.patch
}

build() {
  cd u-boot-${pkgver}
  
  unset CFLAGS CXXFLAGS LDFLAGS
  
  make distclean
  make usbarmory-mark-two_defconfig
  echo 'CONFIG_IDENT_STRING=" Arch Linux ARM"' >> .config
  make EXTRAVERSION=-${pkgrel}
}

package() {
  cd u-boot-${pkgver}

  install -d "${pkgdir}"/boot
  install -Dm644 u-boot-dtb.imx "${pkgdir}"/boot

  install -Dm644 ../boot.txt "${pkgdir}"/boot/boot.txt
  tools/mkimage -A arm -O linux -T script -C none -n "U-Boot boot script" -d ../boot.txt "${pkgdir}"/boot/boot.scr
  install -Dm755 ../mkscr "${pkgdir}"/boot/mkscr
}
